import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_09_game/base/widget/base_list_get_builder.dart';
import 'package:flutter_09_game/base/widget/base_list_more_get_builder.dart';
import 'package:flutter_09_game/config/app_color.dart';
import 'package:flutter_09_game/config/app_routes.dart';
import 'package:flutter_09_game/generated/assets.dart';
import 'package:flutter_09_game/generated/locales.g.dart';
import 'package:flutter_09_game/pages/promotion/models/model_rate_setting.dart';
import 'package:flutter_09_game/user/app_user_manager.dart';
import 'package:flutter_09_game/user/model/app_user_info_model.dart';
import 'package:flutter_09_game/user/model/model_user_wallet.dart';
import 'package:flutter_09_game/utils/extensions/num_ext.dart';
import 'package:flutter_09_game/utils/loading/loading_utils.dart';
import 'package:flutter_09_game/utils/log/utils_log.dart';
import 'package:flutter_09_game/utils/utils_other.dart';
import 'package:flutter_09_game/pages/promotion/models/model_team_member_item.dart';
import 'package:flutter_09_game/widgets/btn_dropdown.dart';
import 'package:flutter_09_game/widgets/button/common_button.dart';
import 'package:flutter_09_game/widgets/button/debounce_gesture_detector.dart';
import 'package:flutter_09_game/widgets/dialog/common_normal_sheet.dart';
import 'package:flutter_09_game/widgets/empty/empty_no_data.dart';
import 'package:flutter_09_game/widgets/image/auto_image.dart';
import 'package:flutter_09_game/widgets/image/image_view.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';

import 'promotion_commission_logic.dart';

class PromotionCommissionPage extends StatelessWidget {
  PromotionCommissionPage({super.key});

  final PromotionCommissionLogic logic = Get.put(PromotionCommissionLogic());

  @override
  Widget build(BuildContext context) {
    return BaseListMoreGetBuilder<PromotionCommissionLogic>(
      // bodyTopViewBuilder: (l) {
      //
      // },
      emptyBuilder: () {
        return Container(
            margin: EdgeInsets.all(16.w),
            padding: EdgeInsets.all(12.w),
            decoration: BoxDecoration(
              color: AppColor.homeTabBackground,
              borderRadius: BorderRadius.circular(12.w),
            ),
            child: Column(
              children: [
                _buildTeamMemberSectionHeader(),
                16.verticalSpaceFromWidth,
                EmptyNoData(
                  message: LocaleKeys.noMembers.tr,
                )
              ],
            ));
      },
      headerBuilder: (l) {
        return Column(
          children: [
            Container(
              padding: EdgeInsets.all(16.w).copyWith(bottom: 24.w),
              decoration: BoxDecoration(
                color: AppColor.navBgColor,
                borderRadius: BorderRadius.only(
                  bottomLeft: Radius.circular(30.w),
                  bottomRight: Radius.circular(30.w),
                ),
              ),
              child: Obx(() {
                ModelUserWallet userWallet =
                    AppUserManager().currentWalletRx.value;
                return _buildCommissionCard(userWallet);
              }),
            ),
            16.verticalSpaceFromWidth,
            _buildPersonalInfoSection()
          ],
        );
      },

      builder: (_) {
        return SliverPadding(
          padding: EdgeInsets.only(bottom: 16.w),
          sliver: SliverToBoxAdapter(
            child: _buildTeamMemberSection(),
          ),
        );

        // return SingleChildScrollView(
        //   padding: EdgeInsets.only(bottom: 16.w),
        //   child: Column(
        //     children: [
        //
        //       16.verticalSpaceFromWidth,
        //       _buildPersonalInfoSecselectItemRxtion(),
        //       16.verticalSpaceFromWidth,
        //       _buildTeamMemberSection(),
        //     ],
        //   ),
        // );
      },
    );
  }

  /// 构建佣金卡片
  Widget _buildCommissionCard(ModelUserWallet userWallet) {
    return Container(
        height: 195.w,
        width: double.infinity,
        padding: EdgeInsets.symmetric(horizontal: 20.w, vertical: 16.w),
        decoration: BoxDecoration(
          // borderRadius: BorderRadius.circular(12.w),
          image: DecorationImage(
              image: AssetImage(userWallet.symbol == 'TRX'
                  ? Assets.promotionMyTopRtx
                  : Assets.promotionMyTopUsdt),
              fit: BoxFit.fill),
        ),
        child:
            // 主要内容
            Row(
          crossAxisAlignment: CrossAxisAlignment.start,
          children: [
            Expanded(
              child: Column(
                crossAxisAlignment: CrossAxisAlignment.start,
                children: [
                  // 顶部：USDT图标和搜索按钮
                  Row(
                    children: [
                      AutoImage(
                        UtilsOther().getAmountTagIcon(userWallet.symbol),
                        width: 32.w,
                      ),
                      8.horizontalSpace,
                      Text(
                        userWallet.symbol ?? '',
                        style: TextStyle(
                          color: Colors.white,
                          fontSize: 20.sp,
                          fontWeight: FontWeight.w900,
                        ),
                      ),
                    ],
                  ),

                  12.verticalSpaceFromWidth,

                  Text(
                    LocaleKeys.myCommission.tr,
                    style: TextStyle(
                      color: Colors.white.withOpacity(0.7),
                      fontSize: 14.sp,
                      fontWeight: FontWeight.w500,
                    ),
                  ),
                  4.verticalSpaceFromWidth,
                  Text(
                    userWallet.rebateBalance?.formatWallet() ?? '',
                    style: TextStyle(
                      color: Colors.white,
                      fontSize: 24.sp,
                      fontWeight: FontWeight.w900,
                    ),
                  ),

                  const Spacer(),

                  // 底部：操作按钮
                  _buildActionButtons(),
                ],
              ),
            ),
            Padding(
                padding: EdgeInsets.only(top: 10.w, right: 4.w),
                child:
                    // Get.toNamed(AppRoutes.depositRecordPage);
                    GestureDetector(
                  onTap: () {
                    Get.toNamed(AppRoutes.depositRecordPage);
                  },
                  child: AutoImage(
                    userWallet.symbol == 'TRX'
                        ? Assets.promotionMyTopRules
                        : Assets.promotionMyTopRUsdt,
                    width: 32.w,
                  ),
                )),
          ],
        ));
  }

  /// 构建操作按钮
  Widget _buildActionButtons() {
    return Row(
      children: [
        // 转为平台余额按钮
        Container(
          height: 32.w,
          padding: EdgeInsets.symmetric(horizontal: 12.w),
          decoration: BoxDecoration(
            color: Colors.white.withOpacity(0.3),
            borderRadius: BorderRadius.circular(96.w),
          ),
          child: TextButton(
            onPressed: () => logic.onTransferToBalance(),
            style: TextButton.styleFrom(
              padding: EdgeInsets.zero,
              minimumSize: Size.zero,
              tapTargetSize: MaterialTapTargetSize.shrinkWrap,
            ),
            child: Text(
              LocaleKeys.transferToPlatformBalance.tr,
              style: TextStyle(
                color: Colors.white,
                fontSize: 12.sp,
                fontWeight: FontWeight.w500,
              ),
            ),
          ),
        ),

        16.horizontalSpace,

        // 提现至钱包按钮
        Container(
          height: 32.w,
          padding: EdgeInsets.symmetric(horizontal: 12.w),
          decoration: BoxDecoration(
            color: Colors.white.withOpacity(0.7),
            borderRadius: BorderRadius.circular(96.w),
          ),
          child: TextButton(
            onPressed: () => logic.onWithdrawToWallet(),
            style: TextButton.styleFrom(
              padding: EdgeInsets.zero,
              minimumSize: Size.zero,
              tapTargetSize: MaterialTapTargetSize.shrinkWrap,
            ),
            child: Text(
              LocaleKeys.withdrawToWallet.tr,
              style: TextStyle(
                color: const Color(0xFF008F50),
                fontSize: 12.sp,
                fontWeight: FontWeight.w500,
              ),
            ),
          ),
        ),
      ],
    );
  }

  /// 构建个人信息板块
  Widget _buildPersonalInfoSection() {
    return Container(
      margin: EdgeInsets.symmetric(horizontal: 16.w),
      padding: EdgeInsets.all(12.w),
      decoration: BoxDecoration(
        color: AppColor.color242631,
        borderRadius: BorderRadius.circular(12.w),
      ),
      child: Column(
        children: [
          // 标题区域
          SizedBox(
            height: 32.w,
            child: Row(
              children: [
                AutoImage(
                  Assets.promotionCommissionUserPersonage,
                  width: 24.w,
                  height: 24.w,
                ),
                12.horizontalSpace,
                Expanded(
                  child: Text(
                    LocaleKeys.personalInfo.tr,
                    style: TextStyle(
                      fontSize: 16.sp,
                      fontWeight: FontWeight.w600,
                      color: AppColor.textPrimary.withOpacity(0.94),
                    ),
                  ),
                ),
              ],
            ),
          ),
          12.verticalSpaceFromWidth,
          // 信息卡片列表
          Obx(() {
            AppUserInfoModelUser? user = AppUserManager().user.value;
            AppUserInfoModelTeam? team = AppUserManager().teamRx.value;

            return Column(
              children: [
                _buildInfoCard(LocaleKeys.myAccount.tr, user?.username ?? '--'),
                4.verticalSpaceFromWidth,
                _buildMemberIdCard(
                    LocaleKeys.memberId.tr, user?.identity ?? '--'),
                4.verticalSpaceFromWidth,
                _buildInfoCard(LocaleKeys.rebateRate.tr,
                    user?.rebateRate?.formatRebateRate() ?? '--'),
                4.verticalSpaceFromWidth,
                _buildInfoCard(LocaleKeys.directUsers.tr,
                    '${team?.directUsersCount ?? 0}'),
                4.verticalSpaceFromWidth,
                _buildInfoCard(LocaleKeys.todayNewUsers.tr,
                    '${team?.todayNewUsersCount ?? 0}'),
                4.verticalSpaceFromWidth,
                _buildInfoCard(LocaleKeys.todayTeamNewUsers.tr,
                    '${team?.todayNewTeamUsersCount ?? 0}'),
                4.verticalSpaceFromWidth,
                _buildInfoCard(LocaleKeys.teamMembers.tr,
                    '${(team?.indirectUsersCount ?? 0) + 1}'),
              ],
            );
          }),
        ],
      ),
    );
  }

  /// 构建普通信息卡片
  Widget _buildInfoCard(String label, String value) {
    return Container(
      padding: EdgeInsets.symmetric(horizontal: 12.w, vertical: 12.w),
      decoration: BoxDecoration(
        color: AppColor.homeTabBackground,
        borderRadius: BorderRadius.circular(8.w),
      ),
      child: Row(
        children: [
          Expanded(
            child: Text(
              label,
              style: TextStyle(
                fontFamily: 'PingFang SC',
                fontSize: 12.sp,
                fontWeight: FontWeight.w400,
                color: AppColor.textPrimary.withOpacity(0.7),
              ),
            ),
          ),
          Text(
            value,
            style: TextStyle(
              fontFamily: 'PingFang SC',
              fontSize: 12.sp,
              fontWeight: FontWeight.w600,
              color: AppColor.textPrimary.withOpacity(0.94),
            ),
          ),
        ],
      ),
    );
  }

  /// 构建会员ID卡片（带复制功能）
  Widget _buildMemberIdCard(String label, String value) {
    return GestureDetector(
      onTap: () => UtilsOther.copyMemberId(value),
      child: Container(
          padding: EdgeInsets.symmetric(horizontal: 12.w, vertical: 12.w),
          decoration: BoxDecoration(
            color: AppColor.homeTabBackground,
            borderRadius: BorderRadius.circular(8.w),
          ),
          child: Row(
            children: [
              Expanded(
                child: Text(
                  label,
                  style: TextStyle(
                    fontFamily: 'PingFang SC',
                    fontSize: 12.sp,
                    fontWeight: FontWeight.w400,
                    color: AppColor.textPrimary.withOpacity(0.7),
                  ),
                ),
              ),
              Row(
                children: [
                  Text(
                    value,
                    style: TextStyle(
                      fontFamily: 'PingFang SC',
                      fontSize: 12.sp,
                      fontWeight: FontWeight.w600,
                      color: AppColor.textPrimary.withOpacity(0.94),
                    ),
                  ),
                  8.horizontalSpace,
                  AutoImage(
                    Assets.promotionCommissionCopy,
                    width: 16.w,
                    height: 16.w,
                  ),
                ],
              ),
            ],
          )),
    );
  }

  /// 格式化返佣比例
  // String _formatRebateRate(int? rebateRate) {
  //   if (rebateRate == null) return '--';
  //   return '${(rebateRate / 100).toStringAsFixed(2)}%';
  // }

  Widget _buildTeamMemberSectionHeader() {
    return Row(
      children: [
        AutoImage(
          Assets.promotionCommissionUserTeam,
          width: 24.w,
          height: 24.w,
        ),
        12.horizontalSpace,
        Expanded(
          child: Text(
            LocaleKeys.teamMembers.tr,
            style: TextStyle(
              fontFamily: 'PingFang SC',
              fontSize: 16.sp,
              fontWeight: FontWeight.w600,
              color: AppColor.textPrimary.withOpacity(0.94),
            ),
          ),
        ),
      ],
    );
  }

  /// 构建团队成员板块
  Widget _buildTeamMemberSection() {
    return Container(
      margin: EdgeInsets.symmetric(horizontal: 16.w).copyWith(top: 16.w),
      padding: EdgeInsets.all(12.w),
      decoration: BoxDecoration(
        color: AppColor.homeTabBackground,
        borderRadius: BorderRadius.circular(12.w),
      ),
      child: Column(
        children: [
          // 标题区域
          _buildTeamMemberSectionHeader(),
          16.verticalSpaceFromWidth,
          // 团队成员列表
          Obx(() {
            if (logic.hasMembers.value == false) {
              return EmptyNoData(
                message: LocaleKeys.noMembers.tr,
              );
            }

            return ListView.separated(
              shrinkWrap: true,
              physics: const NeverScrollableScrollPhysics(),
              itemCount: logic.list.length,
              separatorBuilder: (context, index) => 16.verticalSpaceFromWidth,
              itemBuilder: (context, index) {
                return _buildMemberCard(logic.list[index]);
              },
            );
          }),
        ],
      ),
    );
  }

  /// 构建单个成员卡片
  Widget _buildMemberCard(ModelTeamMemberItem member) {
    return Container(
      padding: EdgeInsets.all(12.w),
      decoration: BoxDecoration(
        color: AppColor.color242631,
        borderRadius: BorderRadius.circular(12.w),
      ),
      child: Column(
        children: [
          // 成员信息区域
          Row(
            children: [
              // 头像
              Container(
                  width: 44.w,
                  height: 44.w,
                  decoration: BoxDecoration(
                    borderRadius: BorderRadius.circular(22.w),
                    border: Border.all(
                      color: AppColor.color22242A,
                      width: 1.w,
                    ),
                  ),
                  child: Stack(
                    children: [
                      Positioned.fill(
                          child: ImageView(
                        imageUrl: member.avatar,
                        radius: 22.w,
                        fit: BoxFit.cover,
                      )),
                      Positioned(
                        bottom: 0,
                        right: 0,
                        child: Container(
                          width: 16.w,
                          height: 16.w,
                          decoration: BoxDecoration(
                            color: AppColor.homePrizePoolBgIndicator
                                .withOpacity(0.12),
                            shape: BoxShape.circle,
                          ),
                          child: Center(
                            child: Container(
                              width: 8.w,
                              height: 8.w,
                              decoration: const BoxDecoration(
                                color: AppColor.homePrizePoolIndicator,
                                shape: BoxShape.circle,
                              ),
                            ),
                          ),
                        ),
                      )
                    ],
                  )),
              12.horizontalSpace,
              // 用户信息
              Expanded(
                child: Column(
                  crossAxisAlignment: CrossAxisAlignment.start,
                  children: [
                    // 用户名和直属人数
                    Row(
                      children: [
                        Flexible(
                          child: Text(
                            member.username ?? '--',
                            style: TextStyle(
                              fontFamily: 'PingFang SC',
                              fontSize: 12.sp,
                              fontWeight: FontWeight.w500,
                              color: AppColor.textPrimary.withOpacity(0.94),
                            ),
                          ),
                        ),
                        8.horizontalSpace,
                        // 直属人数

                        AutoImage(
                          Assets.promotionCommissionUser,
                          width: 16.w,
                          height: 16.w,
                        ),

                        // 4.horizontalSpace,
                        Text(
                          '${(member.teamMemberCount ?? 0) + 1}',
                          style: TextStyle(
                            fontFamily: 'PingFang SC',
                            fontSize: 14.sp,
                            fontWeight: FontWeight.w400,
                            color: AppColor.textPrimary.withOpacity(0.7),
                          ),
                        ),
                      ],
                    ),
                    // 4.verticalSpaceFromWidth,
                    // 会员ID
                    DebounceGestureDetector(
                        onTap: () =>
                            UtilsOther.copyMemberId(member.identity ?? ''),
                        child: Row(
                          children: [
                            Flexible(
                              child: Text(
                                '${LocaleKeys.memberId.tr}：${member.identity ?? '--'}',
                                style: TextStyle(
                                  fontFamily: 'PingFang SC',
                                  fontSize: 12.sp,
                                  fontWeight: FontWeight.w400,
                                  color: AppColor.textPrimary.withOpacity(0.7),
                                ),
                              ),
                            ),
                            4.horizontalSpace,
                            AutoImage(
                              Assets.promotionCommissionCopy,
                              width: 16.w,
                              height: 16.w,
                            ),
                          ],
                        )),
                    4.verticalSpaceFromWidth,
                    // 投注地址
                    Text(
                      '${LocaleKeys.betAddress.tr}：${UtilsOther.formatWithdrawAddress(member.withdrawAddress)}',
                      style: TextStyle(
                        fontFamily: 'PingFang SC',
                        fontSize: 12.sp,
                        fontWeight: FontWeight.w400,
                        color: AppColor.textPrimary.withOpacity(0.7),
                      ),
                    ),
                  ],
                ),
              ),

              Obx(() {
                return Visibility(
                  visible: (AppUserManager().user.value?.rebateRate ?? 0) > 0,
                  child: DebounceGestureDetector(
                    onTap: () => showSetCommissionRate(member),
                    child: AutoImage(
                      Assets.promotionCommissionSetting,
                      width: 32.w,
                      height: 32.w,
                      // color: AppColor.textPrimary.withOpacity(0.94),
                    ),
                  ),
                );
              })
            ],
          ),
          12.verticalSpaceFromWidth,
          // 数据卡片区域
          Obx(() {
            return _buildMemberDataCards(member);
          }),
        ],
      ),
    );
  }

  /// 构建成员数据卡片
  Widget _buildMemberDataCards(ModelTeamMemberItem member) {
    return Row(
      children: [
        Expanded(
          child: _buildDataCard(
              LocaleKeys.balance.tr,
              member.rebateBalance?.formatWallet() ?? '--',
              UtilsOther().getAmountTagIcon(
                  AppUserManager().currentWalletRx.value.symbol),
              //  Assets.commonTrxTag,
              Assets.promotionCommissionItem1),
        ),
        4.horizontalSpace,
        Expanded(
          child: _buildDataCard(
              LocaleKeys.teamBalance.tr,
              member.teamRebateBalance?.formatWallet() ?? '--',
              UtilsOther().getAmountTagIcon(
                  AppUserManager().currentWalletRx.value.symbol),
              Assets.promotionCommissionItem2),
        ),
        4.horizontalSpace,
        Expanded(
          child: _buildDataCard(
              LocaleKeys.commissionRate.tr,
              member.rebateRate?.formatRebateRate() ?? '--',
              null,
              Assets.promotionCommissionItem3),
        ),
      ],
    );
  }

  /// 构建数据卡片
  Widget _buildDataCard(
      String title, String value, String? iconAsset, String bgIcon) {
    return Container(
      padding: EdgeInsets.symmetric(horizontal: 8.w, vertical: 12.w),
      decoration: BoxDecoration(
        color: AppColor.homeTabBackground,
        image: DecorationImage(image: AssetImage(bgIcon), fit: BoxFit.fill),
        borderRadius: BorderRadius.circular(8.w),
      ),
      child: Column(
        children: [
          // 标题和图标
          Row(
            mainAxisAlignment: MainAxisAlignment.center,
            children: [
              if (iconAsset != null) ...[
                AutoImage(
                  iconAsset,
                  width: 16.w,
                  height: 16.w,
                ),
                4.horizontalSpace,
              ],
              Flexible(
                child: Text(
                  title,
                  style: TextStyle(
                    fontFamily: 'PingFang SC',
                    fontSize: 12.sp,
                    fontWeight: FontWeight.w400,
                    color: AppColor.textPrimary.withOpacity(0.7),
                  ),
                ),
              ),
            ],
          ),
          8.verticalSpaceFromWidth,
          // 数值
          Text(
            value,
            style: TextStyle(
              fontSize: 12.sp,
              fontWeight: FontWeight.w900,
              color: AppColor.textPrimary.withOpacity(0.94),
            ),
          ),
        ],
      ),
    );
  }

  showSetCommissionRate(ModelTeamMemberItem member) async {
    if (logic.rateSettingList.isEmpty) {
      await logic.getRebateRateSetting();
    }
    // logic.rateSettingList.clear();
    List<ModelRateSetting> rateSetting = logic.rateSettingList
        .where((item) =>
            (item.rate ?? 0) < (AppUserManager().user.value?.rebateRate ?? 0))
        .toList();
    List<String> items = rateSetting.map((item) => item.name ?? '').toList();
    logic.selectItemRx.value =
        rateSetting.firstWhereOrNull((item) => item.rate == member.rebateRate);
    if (logic.selectItemRx.value == null) {
      if (rateSetting.isNotEmpty) {
        logic.selectItemRx.value = rateSetting.last;
        logic.rebateRateRx.value =
            (logic.selectItemRx.value?.rate ?? 0).formatRebateRate();
      } else {
        logic.rebateRateRx.value = LocaleKeys.pleaseSetCommissionRate.tr;
      }
    } else {
      logic.rebateRateRx.value = (member.rebateRate ?? 0).formatRebateRate();
    }

    Widget selectWidget = Container(
      padding: EdgeInsets.symmetric(horizontal: 10.w, vertical: 12.w),
      decoration: BoxDecoration(
          border: Border(
              bottom: BorderSide(
                  color: AppColor.textPrimary.withOpacity(0.15), width: 1)),
          color: Colors.black.withOpacity(0.3),
          borderRadius: BorderRadius.circular(8.w)),
      child: Row(
        children: [
          Expanded(child: Obx(() {
            return Text(
              logic.rebateRateRx.value,
              style: TextStyle(
                fontSize: 14.sp,
                fontWeight: FontWeight.w900,
                color: AppColor.textPrimary.withOpacity(0.94),
              ),
            );
          })),
          AutoImage(
            Assets.promotionCommissionCaretDown,
            width: 16.w,
          )
        ],
      ),
    );

    CommonNormalSheet(
      title: LocaleKeys.memberSettings.tr,
      child: Container(
        height: 320.w,
        padding: EdgeInsets.symmetric(horizontal: 16.w),
        child: Column(
          crossAxisAlignment: CrossAxisAlignment.start,
          children: [
            Container(
              alignment: Alignment.centerLeft,
              height: 40.w,
              child: Text(
                LocaleKeys.setCommissionRate.tr,
                style: TextStyle(
                  fontSize: 16.sp,
                  fontWeight: FontWeight.w600,
                  color: AppColor.textPrimary.withOpacity(0.94),
                ),
              ),
            ),
            4.verticalSpaceFromWidth,
            items.isNotEmpty
                ? BtnDropdown(
                    items: items,
                    value: logic.selectItemRx.value != null
                        ? (logic.selectItemRx.value?.name ?? '')
                        : items.last,
                    width: 1.sw - 32.w,
                    mainAxisAlignment: MainAxisAlignment.start,
                    onChanged: (value) {
                      logic.rebateRateRx.value = value;
                      logic.selectItemRx.value = logic.rateSettingList
                          .firstWhere((item) => item.name == value);
                    },
                    child: selectWidget)
                : selectWidget,
            8.verticalSpaceFromWidth,
            Text(
              LocaleKeys.warmTips.tr,
              style: TextStyle(
                fontSize: 12.sp,
                fontWeight: FontWeight.w600,
                color: AppColor.primary,
              ),
            ),
            8.verticalSpaceFromWidth,
            RichText(
                text: TextSpan(
                    style: TextStyle(
                      color: AppColor.textPrimary.withOpacity(0.5),
                      fontSize: 12.sp,
                    ),
                    children: [
                  TextSpan(
                    text: LocaleKeys.commissionWarning1.tr,
                  ),
                  TextSpan(
                    text: LocaleKeys.commissionWarning2.tr,
                    style: const TextStyle(
                      color: AppColor.primary,
                      fontWeight: FontWeight.w600,
                      // fontSize: 12.sp,
                    ),
                  ),
                  const TextSpan(
                    text: '，',
                  ),
                  TextSpan(
                    text: LocaleKeys.commissionWarning3.tr,
                    style: const TextStyle(
                      color: AppColor.primary,
                      fontWeight: FontWeight.w600,
                      // fontSize: 12.sp,
                    ),
                  ),
                  const TextSpan(
                    text: '，',
                  ),
                  TextSpan(
                    text: LocaleKeys.commissionWarning4.tr,
                  ),
                ])),
            const Spacer(),
            Obx(() {
              return CommonButton.expend(
                title: LocaleKeys.ok.tr,
                enable: logic.selectItemRx.value != null,
                onClick: () {
                  logic.postUserChangeRebateRate(
                      member, logic.selectItemRx.value);
                },
              );
            }),
            16.verticalSpaceFromWidth,
          ],
        ),
      ),
    ).show();
  }
}
